package com.meevle.vo;

import java.io.Serializable;
import java.util.Date;

public class SlotCommentVO implements Serializable{
	
	private static final long serialVersionUID = 1L;
	private UserVO author;
	
	private SlotVO slot;
	
	private String comment;
	
	private int rating;
	
		//is set automatically when the comment is added to the DB. The client DOES NOT need to set this himself.
		//if he sets it anyway, the value gets overridden without checking
	private Date timeStamp;
	
	
	public UserVO getAuthor() {
		return author;
	}
	
	public void setAuthor(UserVO author) {
		this.author = author;
	}

	public SlotVO getSlot() {
		return slot;
	}
	
	public void setSlot(SlotVO track) {
		this.slot = track;
	}
	
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	public int getRating() {
		return rating;
	}
	
	public void setRating(int rating) {
		this.rating = rating;
	}
	
	public Date getTimeStamp() {
		return timeStamp;
	}
	
	public void setTimeStamp(Date timeStamp) {
		this.timeStamp = timeStamp;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((author == null) ? 0 : author.hashCode());
		result = prime * result + ((comment == null) ? 0 : comment.hashCode());
		result = prime * result + ((slot == null) ? 0 : slot.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SlotCommentVO other = (SlotCommentVO) obj;
		if (author == null) {
			if (other.author != null)
				return false;
		} else if (!author.equals(other.author))
			return false;
		if (comment == null) {
			if (other.comment != null)
				return false;
		} else if (!comment.equals(other.comment))
			return false;
		if (slot == null) {
			if (other.slot != null)
				return false;
		} else if (!slot.equals(other.slot))
			return false;
		return true;
	}
	
	@Override
	public String toString()
	{
		return "\nComment: " +comment
				+ "\nAuthor: " +author.toString()
				+ "\nCommented Track: " +slot.getName()+ " by " +slot.getOwner().getUsername()
				+"\nRating: " + rating; 
	}
	
}
